#include "smart/smart_rga.hpp"
#include "clocker/timer.hpp"

int main(const int argc, const char* argv[])
{
    log_debug("image size:%d.", SmartRga::get_image_size(1920, 1080, RK_FORMAT_UYVY_422));
    Timer* timer = Timer::get_instance();
    int ret;

    uint8_t* src_buf = new uint8_t[2*1920*1080];
    uint8_t* dst_buf = new uint8_t[3*1920*1080];
    SmartRga rga_resize;

    SmartRga::cfg_t rga_src_cfg = {
        .width = 1920,
        .height = 1080,
        .format = RK_FORMAT_YCbCr_420_SP,
        .buffer = src_buf
    };
    SmartRga::cfg_t rga_dst_cfg = {
        .width = 1920,
        .height = 1080,
        .format = RK_FORMAT_UYVY_422,
        .buffer = dst_buf
    };

    ret = rga_resize.init(rga_src_cfg, rga_dst_cfg);
    if (ret) {
        log_error("rga_resize init failed. ret:%d.", ret);
        return -1;
    }

    log_debug("while resize ...");
    while (getchar() != 'q') {
        timer->begin();
        ret = rga_resize.cvtcolor();
        timer->end();
        if (ret) {
            log_error("cvtcolor failed.");
            return -1;
        }
        log_info("rga_resize cvtcolor seccess. diff:%ldus.", timer->get_diff());
    }

    return 0;
}